<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>
    
    <xsl:template match="/">
        <xsl:apply-templates select="." mode="css-validator"/>
    </xsl:template>
    
    <xsl:template match="/" mode="css-validator">
        <xsl:apply-templates select="cruisecontrol/validation" mode="css-validator"/>
    </xsl:template>
    
    <xsl:template match="validation[file/errors/error|file/warnings/warning]" mode="css-validator">
        <xsl:variable name="total.error.count" select="count(file/errors/error)" />
        <xsl:variable name="total.warning.count" select="count(file/warnings/warning)" />
        <table align="center" cellpadding="2" cellspacing="0" border="0" width="98%">
            <tr>
                <td class="modifications-sectionheader" colspan="3">
                    &#160;CSS Validation:&#160;(<xsl:value-of select="$total.error.count"/> errors&#160; 
                                        /&#160; <xsl:value-of select="$total.warning.count"/> warnings)
                </td>
            </tr>

            <xsl:apply-templates mode="css-validator"/>
        </table>
    </xsl:template>
 
    <xsl:template match="file" mode="css-validator">
        <xsl:variable name="error.count" select="count(errors/error)" />
        <xsl:variable name="warning.count" select="count(warnings/warning)" />
        <tr>
            <td class="modifications-data" colspan="3">
                <xsl:value-of select="@url" />&#160;
                (<xsl:value-of select="$error.count" /> errors / 
                 <xsl:value-of select="$warning.count" /> warnings)
            </td>
        </tr>
        
        <xsl:choose>
            <xsl:when test="$error.count > 0">
                <tr>
                    <td class="modifications-data" colspan="3">Errors: (<xsl:value-of select="$error.count" />)</td>
                </tr>
                <xsl:apply-templates select="errors/error" mode="css-validator"/>
            </xsl:when>
        </xsl:choose>
        
        <xsl:choose>
            <xsl:when test="$warning.count > 0">
                <tr>
                    <td class="modifications-data" colspan="3">Warnings: (<xsl:value-of select="$warning.count" />)</td>
                </tr>
                <xsl:apply-templates select="warnings/warning" mode="css-validator"/>
            </xsl:when>
        </xsl:choose>
        
    </xsl:template>
    
    
    <xsl:template match="error" mode="css-validator">
        <tr>
            <xsl:if test="position() mod 2 = 1">
                <xsl:attribute name="class">css-validator-oddrow</xsl:attribute>
            </xsl:if>
            <td class="modifications-data">Line: <xsl:value-of select="@line" /></td>
            <td class="modifications-data">Message: <xsl:value-of select="text()" /></td>
            <td class="modifications-data"><xsl:value-of select="../@name" /></td>
        </tr>
    </xsl:template>
    
    <xsl:template match="warning" mode="css-validator">
        <tr>
            <xsl:if test="position() mod 2 = 1">
                <xsl:attribute name="class">css-validator-oddrow</xsl:attribute>
            </xsl:if>
            <td class="modifications-data">Line: <xsl:value-of select="@line" /></td>
            <td class="modifications-data">Message: <xsl:value-of select="text()" /></td>
            <td class="modifications-data"><xsl:value-of select="../@name" /></td>
        </tr>
    </xsl:template>
    
</xsl:stylesheet>